package com.cssw.fyzb.web.service;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.core.dao.video.VideoHotDefDao;
import com.cssw.fyzb.core.model.dodb.CmfVideoHotDef;
import com.cssw.fyzb.web.dto.CmfVideoHotDefDto;
import com.cssw.fyzb.core.util.BizUtil;
import com.cssw.fyzb.web.util.HashUtil;
import com.cssw.fyzb.web.util.StrUtil;
import com.ydn.dbframe.kit.StrKit;
import com.ydn.dbframe.plugin.activerecord.Db;
import com.ydn.dbframe.plugin.activerecord.Page;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author Feng Chen
 */
@Service
public class CmfVideoHotDefService {

    @Autowired
    private VideoHotDefDao videoHotDefDao;

    private static final Logger logger = LoggerFactory.getLogger(CmfVideoHotDefService.class);

    /**
     * 查询上热门定义列表
     *
     * @param page
     * @param limit
     * @param param
     * @return
     */
    public AjaxPage list(Integer page, Integer limit, Map param) {
        Page<CmfVideoHotDef> pages = videoHotDefDao.adminList(page, limit, param);
        return AjaxPage.success(pages.getList(), pages.getTotalRow(), pages.getTotalPage());
    }

    public AjaxData info(Long hotId) {
        return AjaxData.success(videoHotDefDao.findById(hotId));
    }

    /**
     * 新增上热门定义
     */
    public AjaxData save(Integer hotValue, String hotName, BigDecimal price, Integer hotTime, String hotOprName, String hotOprCode, Long sysOperId) {
        Boolean res = videoHotDefDao.save(hotValue,hotName,price,hotTime,hotOprName,hotOprCode,sysOperId);
        return AjaxData.success(res);
    }

    /**
     * 修改上热门定义
     */
    public AjaxData update(Long hotId, Integer hotValue, String hotName, BigDecimal price, Integer hotTime, String hotOprName, String hotOprCode,Long sysOperId) {
        Boolean res = videoHotDefDao.update(hotId,hotValue,hotName,price,hotTime,hotOprName,hotOprCode,sysOperId);
        return AjaxData.success(res);
    }

    /**
     * 删除上热门定义
     */
    public AjaxData delete(Long hotId,Long sysOperId) {
        Boolean res = videoHotDefDao.delete(hotId,sysOperId);
        return AjaxData.success(res);
    }

}
